<template>
	<view>
		<view class="pore" style="z-index: 999;">
			<u-navbar :title="name || '趣玩黄石'" bgColor="transparent" autoBack :fixed="false">
			</u-navbar>
		</view>
		<view class="ml30 mr30 pore">
			<view>
				<food-list :dataArray="listData"></food-list>
			</view>
		</view>
		<u-gap height="20"></u-gap>
	</view>
</template>

<script>
	import foodList from '@/components/foodList/index.vue'
	import {
		getStorelist
	} from '@/common/api_wan.js'
	export default {
		components: {
			foodList
		},
		name: '',
		data() {
			return {
				name:'',
				id:'',
				longitude:30.205922,
				latitude:115.082256,
				listData: []
			}
		},
		onLoad(option) {
			this.id = option.id
			this.name = option.name
			// #ifdef MP-WEIXIN
			this.getLocation()
			// #endif
			// #ifdef H5
			this.getStorelist()
			// #endif
		},
		methods: {
			getLocation(){
				const that = this
				uni.getLocation({
					success(res) {
						const { latitude, longitude } = res
						that.longitude = longitude
						that.latitude = latitude
						that.getStorelist()
					}
				})
			},
			async getStorelist() {
				uni.showLoading({
					mask: true
				})
				const res = await getStorelist({
					id:this.id,
					longitude:this.longitude,
					latitude:this.latitude
				})
				if (res.code == 200) {
					this.listData = res.data.map(item =>{
						return {
							...item,
							imgs:item.images?item.images.split(','):[]
						}
					})
				}
				uni.hideLoading()
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F1FFED;
	}
	
</style>